<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <title></title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
    <meta name="description" content="">
    <meta name="author" content="">
    <!-- STYLESHEETS --><!--[if lt IE 9]>
    <script src="../../js/flot/excanvas.min.js"></script>
    <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script><![endif]-->
    <link rel="stylesheet" type="text/css" href="../../css/cloud-admin.css">
    <link rel="stylesheet" type="text/css" href="../../css/themes/default.css" id="skin-switcher">
    <link rel="stylesheet" type="text/css" href="../../css/responsive.css">

    <link href="../../font-awesome/css/font-awesome.min.css" rel="stylesheet">

    <!-- SELECT2 -->
    <link rel="stylesheet" type="text/css" href="../../js/select2/select2.min.css"/>
    <!-- UNIFORM -->
    <link rel="stylesheet" type="text/css" href="../../js/uniform/css/uniform.default.min.css"/>
    <!-- datatable -->
    <link rel="stylesheet" href="../../js/datatables/datatable.css">

</head>
<body>
<header class="navbar clearfix" id="header">
</header>

<!-- PAGE -->
<section id="page">
    <!-- SIDEBAR -->
    <div id="sidebar" class="sidebar">
        <div class="sidebar-menu nav-collapse">

            <!-- SIDEBAR MENU -->
            <ul>

            </ul>
            <!-- /SIDEBAR MENU -->
        </div>

    </div>
    <!-- /SIDEBAR -->
    <div id="main-content">
        <!-- 发货日期选择 -->
        <div class="modal fade" id="sales_time_config" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title">设置上架时间</h4>
                    </div>
                    <div class="modal-body">
                        <div class="form-group" style="margin-bottom: 0px">
                            <div class="col-md-12">
                                请设置上架时间，用于前台商品显示时排序
                            </div>
                        </div>
                        <div class="row">
                            <label class="control-label col-md-3" style="line-height:34px;"><span class="required">*</span>上架时间：</label>
                            <div class="col-md-8">
                                <input class="Wdate" style="height:34px" type="text" id="d4311" name="saleTime"
                                       onfocus="WdatePicker({maxDate:'#F{\'2030-10-01\'}',dateFmt:'yyyy-MM-dd'})">
                            </div>
                        </div>
                        <div class="row">
                            <label class="control-label col-md-3" style="line-height:34px;"><span class="required">*</span>上架方式：</label>
                            <div>
                                <input type="radio" name="saleStatus" value="OnSale" checked="checked">上架可见
                                <input type="radio" name="saleStatus" value="Invisible">上架不可见
                            </div>
                        </div>
                    </div>

                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        <button type="button" class="btn btn-success bt-save">保存</button>
                    </div>
                </div>
            </div>
        </div>

        <!-- end -->
        <!-- 上架设置 -->
        <div class="modal fade" id="sales_config" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title">上架设置</h4>
                    </div>
                    <div class="modal-body">
                        <div class="form-group" style="margin-bottom: 0px">
                            <div class="col-md-12">
                                上架类型：上架可见(在列表页显示)，上架不可见(在列表页不显示)
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3" style="line-height:34px;"><span class="required">*</span>上架方式：</label>
                            <div class="col-md-4">
                                <input type="radio" name="saleStatus" value="OnSale" checked="checked">上架可见
                                <input type="radio" name="saleStatus" value="Invisible">上架不可见
                            </div>
                        </div>
                    </div>

                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        <button type="button" class="btn btn-success bt-save">保存</button>
                    </div>
                </div>
            </div>
        </div>
        <!-- SAMPLE BOX CONFIGURATION MODAL FORM-->
        <div class="modal fade" id="productComment_config" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title">商品评价</h4>
                    </div>
                    <div class="modal-body">
                        <div class="form-group" style="margin-bottom: 5px">
                            <label class="control-label col-md-3" style="line-height:34px;">商品名称：</label>
                            <div class="col-md-8 productName" style="line-height:34px;">

                            </div>
                        </div>
                        <div class="form-group" style="margin-bottom: 5px">
                            <label class="control-label col-md-3" style="line-height:34px;">颜色：</label>
                            <div class="col-md-4 color" style="line-height:34px;">

                            </div>
                        </div>
                        <div class="form-group" style="margin-bottom: 5px">
                            <label class="control-label col-md-3" style="line-height:34px;">尺码：</label>
                            <div class="col-md-4">
                                <select id="size_select" class="col-md-12 select2-offscreen" tabindex="-1">

                                </select>
                            </div>
                        </div>
                        <div class="form-group" style="margin-bottom: 5px">
                            <label class="control-label col-md-3" style="line-height:34px;"><span class="required">*</span>评价日期：</label>
                            <div class="col-md-4">
                                <input class="Wdate" style="height:34px" type="text" id="d43112" name="startTime"
                                       onfocus="WdatePicker({maxDate:'#F{\'2030-10-01\'}',dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false,readOnly:true})">
                            </div>
                        </div>
                        <div class="form-group" style="margin-bottom: 5px">
                            <label class="control-label col-md-3" style="line-height:34px;">用户：</label>
                            <div class="col-md-4">
                                <select id="userId_select" class="col-md-12 select2-offscreen" tabindex="-1">
                                    <option value='38'>一生一世</option>
                                    <option value='39'>小鱼妈妈</option>
                                    <option value='40'>小鸽子</option>
                                    <option value='41'>vivi</option>
                                    <option value='42'>lucy</option>
                                    <option value='43'>米格</option>
                                    <option value='44'>温仪</option>
                                    <option value='45'>快乐的苹果</option>
                                    <option value='46'>飞鸟</option>
                                    <option value='47'>常悦</option>
                                    <option value='25025'>豆豆妈</option>
                                    <option value='25026'>佳佳</option>
                                    <option value='25029'>可爱淘</option>
                                    <option value='25031'>黑糖玛奇朵</option>
                                    <option value='25033'>香草咖啡</option>
                                    <option value='25035'>甜甜圈</option>
                                    <option value='25038'>端端</option>
                                    <option value='25039'>小五家</option>
                                    <option value='25040'>houhou</option>
                                    <option value='25041'>迟迟</option>
                                    <option value='25045'>奔奔</option>
                                    <option value='25046'>归去</option>
                                    <option value='25048'>放开</option>
                                    <option value='25052'>后来</option>
                                    <option value='25053'>蓉蓉</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group" style="margin-bottom: 5px">
                            <label class="control-label col-md-3" style="line-height:34px;"><span class="required">*</span>标签：</label>
                            <div class="col-md-8">
                                <label class="checkbox-inline"><input type="checkbox" name="commentTag" value="很喜欢"/>很喜欢</label>
                                <label class="checkbox-inline"><input type="checkbox" name="commentTag" value="百搭"/>百搭</label>
                                <label class="checkbox-inline"><input type="checkbox" name="commentTag" value="颜色正"/>颜色正</label>
                                <label class="checkbox-inline"><input type="checkbox" name="commentTag" value="舒服"/>舒服</label>
                                <label class="checkbox-inline"><input type="checkbox" name="commentTag" value="柔软"/>柔软</label>
                                <label class="checkbox-inline" style="margin-left:0px;padding:0">(最多选择3个)
                                </label>
                            </div>

                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3" style="line-height:34px;"><span class="required">*</span>评价：</label>
                            <div class="col-md-4">
                                <textarea cols="10" rows="3" name="content" class="form-control" style="width:280px;resize:none;"></textarea>

                            </div>
                        </div>
                    </div>
                    <input name="productId" type="hidden">
                    <div class="modal-footer" style="text-align: center;">
                        <button type="button" class="btn btn-success bt-save">仅保存</button>
                        <button type="button" class="btn btn-success bt-save">保存并查看</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="modal fade" id="update_pre_sales_config" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title">设置预售</h4>
                    </div>
                    <div class="modal-body">
                        <div class="form-group">
                            <label class="control-label col-md-3" style="line-height:34px;"><span class="required">*</span>预售日期：</label>
                            <div class="col-md-4">
                                <input class="Wdate" style="height:34px" type="text" id="d4312" name="preSaleDate"
                                       onfocus="WdatePicker({maxDate:'#F{\'2030-10-01\'}',dateFmt:'yyyy-MM-dd'})">
                            </div>
                        </div>
                    </div>

                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        <button type="button" class="btn btn-success bt-save">保存</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="modal fade" id="update_productName_config" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title">批量更新产品名称</h4>
                    </div>
                    <div class="modal-body">
                        <div class="row">
                            <label class="control-label col-md-3" style="line-height:34px;"><span class="required">*</span>原产品名称：</label>
                            <div class="col-md-4">
                                <input class="form-control" style="height:34px;width:350px;" type="text" name="searchKey" placeholder="输入要替换的名称">
                            </div>
                        </div>
                        <div class="row">
                            <label class="control-label col-md-3" style="line-height:34px;"><span class="required">*</span>替换为：</label>
                            <div class="col-md-4">
                                <input class="form-control" style="height:34px;width:350px;" type="text" name="distProductName" placeholder="去掉原产品名称请输入空格/加前缀">
                            </div>
                        </div>
                        <div class="row">
                            <label class="control-label col-md-3" style="line-height:34px;"><span class="required">*</span>按产品：</label>
                            <div class="col-md-6">
                                <input class="form-control col-md-6" type="text" name="q" placeholder="请输入关键字">
                            </div>
                            <div class="col-md-1">
                                <a class="btn btn-primary searchProductName">查询</a>
                            </div>
                        </div>
                        <div class="row">
                            <table id="td_selectproduct" cellpadding="0" cellspacing="0" border="0"
                                   class="datatable table table-striped table-bordered table-hover">
                            </table>
                        </div>
                    </div>

                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        <button type="button" class="btn btn-success bt-save">保存</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="modal fade" id="update_price_config" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title">修改价格</h4>
                    </div>
                    <div class="modal-body">
                        <div class="row">
                            <input name=id type="hidden">
                            <label class="control-label col-md-3" style="line-height:34px;"><span class="required">*</span>商品名称：</label>
                            <div class="col-md-4 " style="line-height:34px;">
                                <input class="form-control" style="height:34px;width:350px;" type="text" name="productName">
                            </div>
                        </div>
                        <div class="row">
                            <label class="control-label col-md-3" style="line-height:34px;"><span class="required">*</span>销售价：</label>
                            <div class="col-md-4">
                                <input class="form-control" style="height:34px" type="text" name="productSalePrice" onkeypress="return $.IsDecimal(event);"
                                       onblur="return $.IsMoney(this);">
                            </div>
                        </div>
                        <div class="row" id="vipRate_config">
                            <label class="control-label col-md-3" style="line-height:34px;"><span class="required">*</span>女王价折扣：</label>
                            <div class="col-md-4">
                                <select id="vipRate_select" name="vipRate">
                                    <option></option>
                                    <option value="0.00">0%</option>
                                    <option value="0.05">5%</option>
                                    <option value="0.10">10%</option>
                                    <option value="0.15">15%</option>
                                    <option value="0.20">20%</option>
                                    <option value="0.25">25%</option>
                                    <option value="0.30">30%</option>
                                    <option value="0.35">35%</option>
                                </select>
                                <span class="error-span"></span>
                            </div>
                        </div>
                        <div class="row">
                            <label class="control-label col-md-3" style="line-height:34px;">会员价：</label>
                            <div class="col-md-4">
                                <input class="form-control" readonly="readonly" style="height:34px" type="text" name="vipPrice"
                                       onkeypress="return $.IsDecimal(event);" onblur="return $.IsMoney(this);">
                            </div>
                        </div>

                        <div class="row">

                            <label class="control-label col-md-3" style="line-height:34px;">分销价：</label>
                            <div class="col-md-4">
                                <input class="form-control" style="height:34px" type="text" name="distributionPrice" onkeypress="return $.IsDecimal(event);"
                                       onblur="return $.IsMoney(this);">
                            </div>
                        </div>
                        <div class="row">

                            <label class="control-label col-md-3" style="line-height:34px;">拼团价：</label>
                            <div class="col-md-4">
                                <input class="form-control" style="height:34px" type="text" name="promotionPrice" onkeypress="return $.IsDecimal(event);"
                                       onblur="return $.IsMoney(this);">
                            </div>
                        </div>
                        <div class="row">
                            <label class="control-label col-md-3" style="line-height:34px;"><span class="required">*</span>分享返利：</label>
                            <div class="col-md-4">
                                <input name="shareRate" class="form-control" onkeypress="return $.IsDecimal(event);" onblur="return $.IsMoney(this);"
                                       maxlength=4>

                                <span class="error-span"></span>
                            </div>
                        </div>
                        <div class="row">
                            <label class="control-label col-md-12 required" style="line-height:34px;">所有尺码都会更新为当前价格，尺码价格不同请使用编辑功能</label>

                        </div>
                    </div>

                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        <button type="button" class="btn btn-success bt-updateprice">保存</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="modal fade" id="push_off_shop_config" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title">推送到线下店</h4>
                    </div>
                    <div class="modal-body">
                        <div class="row">
                            <div class="col-md-4 " style="line-height:34px;">
                                <input type="checkbox" name="offShop" value="Kids">
                                <span>新世界</span>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-4 " style="line-height:34px;">
                                <input type="checkbox" name="offShop" value="TaiYangGong">
                                <span>太阳宫</span>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        <button type="button" class="btn btn-success bt-push">推送</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="container">
            <div class="row">
                <div id="content" class="col-lg-12">
                    <!-- PAGE HEADER-->
                    <div class="row">
                        <div class="col-sm-12">
                            <div class="page-header">
                                <!-- STYLER -->

                                <!-- /STYLER -->
                                <!-- BREADCRUMBS -->
                                <ul class="breadcrumb">
                                    <li>
                                        <i class="fa fa-home"></i>
                                        <a href="../index.html">首页</a>
                                    </li>
                                    <li>
                                        <a href="#">商品管理</a>
                                    </li>
                                    <li>商品列表</li>
                                </ul>
                                <!-- /BREADCRUMBS -->

                            </div>
                        </div>
                    </div>
                    <!-- /PAGE HEADER -->
                    <!-- FORMS QUERY-->
                    <div class="row">
                        <div class="col-md-12">
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="box border primary">
                                        <div class="box-title">
                                            <h4><i class="fa fa-bars"></i>查询条件</h4>
                                        </div>
                                        <div class="box-body big" style="padding:10px;">
                                            <form class="form-horizontal" role="form" id="export" action="../../admin/product/exportProduct.do">
                                                <div class="form-group mrg-bt10">
                                                    <label class="col-sm-1 control-label" style="width: auto">商品名称：</label>
                                                    <div class="col-sm-2">
                                                        <input type="text" class="form-control" name="productName" placeholder="输入关键字">
                                                    </div>
                                                    <label class="col-sm-1 control-label" style="width: auto">商品款式：</label>
                                                    <div class="col-sm-2">
                                                        <input type="text" class="form-control" name="groupName" placeholder="输入关键字">
                                                    </div>
                                                    <label class="col-sm-1 control-label" for="e1" style="width: auto">商品状态：</label>
                                                    <div class="col-sm-2">
                                                        <select id="salesStatus" name="salesS" class="col-md-12 select2-offscreen" tabindex="-1">
                                                            <option value="-1">选择状态</option>
                                                            <option value="OnSale">上架</option>
                                                            <option value="Invisible">上架不可见</option>
                                                            <option value="InStock">下架</option>

                                                        </select>
                                                    </div>
                                                    <div class="col-sm-2" style="width: 120px">
                                                        <input type="checkbox" name="special"><span style='margin-left:10px'>特例品</span>
                                                    </div>
                                                    <div class="col-sm-2" style="width: 120px">
                                                        <input type="checkbox" name="preDate"><span style='margin-left:10px'>预售</span>
                                                    </div>

                                                </div>
                                                <div class="form-group mrg-bt10">
                                                    <label class="col-sm-1 control-label" style="width: auto">商品编号：</label>
                                                    <div class="col-sm-2">
                                                        <input type="text" class="form-control" name="productCode" placeholder="输入关键字">
                                                    </div>
                                                    <div class="col-sm-2 tuan" style="width: 120px">
                                                        <input type="checkbox" name="isGroup"><span style='margin-left:10px'>是否拼团</span>
                                                    </div>
                                                    <div class="col-sm-2 tuan" style="width: 210px">
                                                        <input type="checkbox" name="vipPrice"><span style='margin-left:10px'>是否女王价</span>
                                                    </div>
                                                    <label class="col-sm-1 control-label" style="width: auto">所属店铺：</label>
                                                    <div class="col-sm-2">
                                                        <input type="text" class="form-control" name="supplierName" placeholder="输入关键字">
                                                    </div>
                                                    <label class="col-sm-1 control-label" for="e1" style="width: auto">销售平台：</label>
                                                    <div class="col-sm-1">
                                                        <select id="salesPlatform" name="salesPlatform" class="col-md-12 select2-offscreen" tabindex="-1">
                                                            <option value="">全部</option>
                                                            <option value="Yiigoo">壹果</option>
                                                            <option value="Yijiadian">壹家店</option>

                                                        </select>
                                                    </div>
                                                    <div class="col-sm-1">
                                                        <a class="btn btn-primary search">查询</a>
                                                    </div>
                                                </div>
                                            </form>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- /FORMS QUERY -->
                    <div class="row" style="height: 30px;">
                        <div class="col-md-12">
                            <div class="box ">
                                <a href="add_product.html" class="btn btn-success config">
                                    <i class="fa  fa-plus-square-o"></i> 新增商品
                                </a>
                                <a href="javascript:;" class="btn btn-warning export">
                                    <i class="fa  fa-copy"></i> 导出商品
                                </a>
                                <a href="javascript:;" class="btn btn-danger batchUpdateName">
                                    <i class="fa  fa-copy"></i> 批量更新产品名称
                                </a>
                            </div>
                        </div>
                    </div>

                    <div class="row">
                        <!-- TABLES -->
                        <div class="col-md-12">
                            <!-- BOX -->
                            <div class="box border primary">
                                <div class="box-title">
                                    <h4><i class="fa fa-table"></i>商品数：<span id="total"></span>条 </h4>
                                </div>
                                <div class="box-body">
                                    <table id="db_product_list" cellpadding="0" cellspacing="0" border="0"
                                           class="datatable table table-striped table-bordered table-hover">

                                    </table>
                                </div>
                            </div>
                            <!-- /BOX -->
                        </div>
                    </div>
                    <!-- /TABLES -->


                    <div class="footer-tools">
							<span class="go-top">
								<i class="fa fa-chevron-up"></i> Top
							</span>
                    </div>
                </div><!-- /CONTENT-->
            </div>
        </div>
    </div>
</section>
<!--/PAGE -->
<!-- JAVASCRIPTS -->
<!-- Placed at the end of the document so the pages load faster -->
<!-- JQUERY -->
<script src="../../js/jquery/jquery-2.0.3.min.js"></script>
<!-- JQUERY UI-->
<script src="../../js/jquery-ui-1.10.3.custom/js/jquery-ui-1.10.3.custom.min.js"></script>
<!-- BOOTSTRAP -->
<script src="../../bootstrap-dist/js/bootstrap.min.js"></script>
<!-- BLOCK UI -->
<script type="text/javascript" src="../../js/jQuery-BlockUI/jquery.blockUI.min.js"></script>

<!-- AUTOSIZE -->
<script type="text/javascript" src="../../js/autosize/jquery.autosize.min.js"></script>
<!-- spinner -->
<script src="../../js/spinner/spin.js"></script>
<!-- DATA TABLES -->
<script type="text/javascript" src="../../js/datatables/bootstrap-select.js"></script>
<script type="text/javascript" src="../../js/datatables/datatable.js"></script>
<script type="text/javascript" src="../../js/datatables/datatable-bootstrap.js"></script>
<script type="text/javascript" src="../../js/datatables/datatable-tabletools.js"></script>
<script type="text/javascript" src="../../js/datatables/fnAddTr.js"></script>

<!-- INPUT MASK -->
<script type="text/javascript" src="../../js/bootstrap-inputmask/bootstrap-inputmask.min.js"></script>
<!--bootbox-->
<script type="text/javascript" src="../../js/bootbox/bootbox.min.js"></script>
<!-- SELECT2 -->
<script type="text/javascript" src="../../js/select2/select2.min.js"></script>
<!-- UNIFORM -->
<script type="text/javascript" src="../../js/uniform/jquery.uniform.min.js"></script>
<script language="javascript" type="text/javascript" src="../../js/My97DatePicker/WdatePicker.js"></script>
<!-- COOKIE -->
<script type="text/javascript" src="../../js/jQuery-Cookie/jquery.cookie.min.js"></script>
<!-- CUSTOM SCRIPT -->
<script src="../../js/script.js"></script>
<script src="../../js/common.js"></script>
<script>
    var Product = function () {
        var $mainDataTable = null, id = null, status = null, selectProducts = [];
        var deleteProduct = function () {
            var tr = $(this).closest("tr");
            if ($(tr).find(".saleStatus").html() != "下架") {
                $.alert("请先下架再删除！");
                return;
            } else {
                $.confirm("确认删除此商品?", function () {
                    $.ajax({
                        type: "post",
                        url: App.getContextPath() + "admin/product/updateProductStatus.do",
                        async: true,
                        data: {
                            id: $(tr).find(".id").html()
                        },
                        success: function (result) {
                            searchProduct();
                        }
                    });
                });
            }
        };
        var updatePreSales = function () {
            var productId = $(this).attr("id");
            var preSaleDate = $(this).attr("preSaleDate");
            if (preSaleDate != null && preSaleDate != 'null') {
                $("#update_pre_sales_config").find("input").val($.getLocalDate(preSaleDate));
            } else {
                $("#update_pre_sales_config").find("input").val("");

            }
            $("#update_pre_sales_config").modal("show");
            $(".bt-save").unbind("click").click(function () {

                var preSaleDate = $("#update_pre_sales_config").find("input").val();
                $.ajax({
                    type: "get",
                    url: App.getContextPath() + "admin/product/updatePreSaleDate.do",
                    async: true,
                    data: {id: productId, preSaleDate: $("[name=preSaleDate]").val()},
                    success: function (result) {
                        if (result.type == "success") {
                            $("#update_pre_sales_config").modal("hide");
                            $.alert("修改成功");
                        } else {
                            $("#update_pre_sales_config").modal("hide");
                            $.alert("修改失败");
                        }
                        //searchProduct();
                    }

                });
            });
        }
        //添加商品评价
        var showProductComment = function () {
            var date = new Date();
            $("[name=startTime]").val(date.format("yyyy-MM-dd hh:mm:ss"));
            var tr = $(this).closest("tr");
            $(".productName").html($(this).attr("productName"));

            $(".color").html($(tr).find(".color").html());
            $("[name=productId]").val($(tr).find(".id").html())
            $("[name=content]").val("");
            //获取产品的尺码
            $.ajax({
                type: "post",
                url: App.getContextPath() + "admin/product/getSkuByProductId.do",
                async: true,
                data: {productId: $(tr).find(".id").html()},
                success: function (result) {
                    var option = "";
                    if (result != null) {
                        $.each(result, function (index, item) {
                            option += "<option value='" + item.id + "'>" + item.sizeName + "</option>";
                        });
                        $("#size_select").empty().append(option).select2();
                        $("#userId_select").select2();
                        $("#productComment_config").modal("show");
                        $(".bt-save").unbind("click").click(addProductComment);
                    }

                }

            });


        }
        var addProductComment = function () {
            var that = $("#productComment_config");
            var index = $(this).index();

            var tags = [];
            $("input[type=checkbox]:checked").each(function () {
                tags.push($(this).val());
            })
            if (tags.length == 0) {
                $.alert("请选择评价标签");
                return false;
            }
            if (tags.length > 3) {
                $.alert("评价标签最多选择3个");
                return false;
            }
            if ($("[name=content]").val().trim().length == 0) {
                $.alert("请输入评价内容");
                return false;
            }
            var p = {};
            p.orderId = 0;
            p.productId = $(that).find("[name=productId]").val();

            p.skuId = $("#size_select").val();
            p.userId = $("#userId_select").val();
            ;
            p.content = $("[name=content]").val();
            p.commentTag = tags.toString();

            $.ajax({
                type: "post",
                url: App.getContextPath() + "admin/productComment/addProductComment.do",
                async: true,
                data: $.param({productComment: JSON.stringify(p), createTime: $("[name=startTime]").val()}),
                success: function (result) {
                    $("#productComment_config").modal("hide");
                    if (index == 1)
                        window.location.href = "../publish/product_comment.html?name=" + $(".productName").html();
                }
            });

        }
        //更新销售价和商品名称
        var updatePrice = function () {


            $("#update_price_config").find("#vipRate_select").select2({placeholder: "选择女王价比例"});
            $("#update_price_config").find("select").select2("val", "请选择");
            $("#update_price_config").find("[name=productSalePrice]").val($(this).attr("productSalePrice"));
            $("#update_price_config").find("[name=vipPrice]").val($(this).attr("vipPrice"));
            $("#update_price_config").find("[name=promotionPrice]").val($(this).attr("promotionPrice") == 'null' ? '0' : $(this).attr("promotionPrice"));
            $("#update_price_config").find("[name=distributionPrice]").val($(this).attr("distributionPrice") == 'null' ? '0' : $(this).attr("distributionPrice"));
            $("#update_price_config").find("[name=id]").val($(this).attr("id"));
            $("[name=shareRate]").val($(this).attr("shareRate"));

            //$("#update_price_config").find(".productName").html();
            $("#update_price_config").find("[name=productName]").val($(this).closest("tr").find(".productName").html());

            /* 		if($(this).attr("promotionPrice") && $(this).attr("promotionPrice") > 0){
                         $("#vipRate_select").select2("val",$(this).attr("shareRate"));
                        vipRateChange($(this).attr("shareRate"));
                    } */
            $("#update_price_config").modal("show");
            $(".bt-updateprice").unbind().click(function () {
                if ($("#update_price_config").find("[name=productName]").val().trim().length == 0) {
                    $.alert("请输入商品名称");
                    return false;
                }
                var shareRate = $("#update_price_config").find("[name=shareRate]").val();
                if (shareRate == null || shareRate == '') {
                    $.alert("请输入分享返利");
                    return false;
                }
                var vipRate = $("#update_price_config").find("[name=vipRate]").val();
                if (vipRate == null || vipRate == '') {
                    $.alert("请选择女王价比例");
                    return false;
                }
                var p = {};
                p.id = $("#update_price_config").find("[name=id]").val();
                p.productSalePrice = $("#update_price_config").find("[name=productSalePrice]").val();
                p.productName = $("#update_price_config").find("[name=productName]").val();
                p.vipPrice = $("#update_price_config").find("[name=vipPrice]").val();
                p.promotionPrice = $("#update_price_config").find("[name=promotionPrice]").val();
                p.distributionPrice = $("#update_price_config").find("[name=distributionPrice]").val();
                p.shareRate = shareRate;

                $.ajax({
                    type: "post",
                    url: App.getContextPath() + "admin/product/updateSalesPrice.do",
                    async: true,
                    data: $.param({product: JSON.stringify(p)}),
                    success: function (result) {
                        console.log(result)
                        if (result.type === 'success') {
                            $.alert("更新成功");
                            $("#update_price_config").modal("hide");
                        } else {
                            $.alert(result.content);
                        }

                        //searchProduct();
                    }
                });
            });
        }
        //设置为特里品
        var siteSpecial = function () {
            var productId = $(this).attr("id");
            var isSpecial = $(this).attr("isSpecial");
            var content;
            if (isSpecial == 'true') {
                content = "是否取消特例品";
                isSpecial = false;
            } else {
                content = "是否将该商品设置为特例品";
                isSpecial = true;

            }

            $.confirm(content, function () {
                $.ajax({
                    type: "get",
                    url: App.getContextPath() + "admin/product/siteSpecial.do",
                    async: true,
                    data: {
                        id: productId, isSpecial: isSpecial
                    },
                    success: function (result) {
                        if (result.type == 'error') {
                            $.alert(result.content)
                        }

                        //searchProduct();
                    }
                });

            });
        }


        var searchProduct = function () {
            var groupName = $("[name=groupName]").val();
            var status = $("#salesStatus").val();
            var q = $("#export").find("input[name=productName]").val();
            var productNumber = $("input[name=productCode]").val();
            var special = $("[name=special]").prop("checked");
            var supplierName = $("[name=supplierName]").val();

            var url = App.getContextPath() + "admin/product/searchProduct.do?q=" + q + "&isSpecial=" + special + "&productCode=" + productNumber + "&isGroup=" + $("[name=isGroup]").prop("checked") + "&preSaleDate=" + $("[name=preDate]").prop("checked");
            if (supplierName != null)
                url += "&supplierName=" + supplierName;
            if (groupName != "" && groupName != null)
                url += "&groupName=" + groupName
            if (status != -1 && status != null)
                url += "&productStatus=" + status
            if ($("#export").find("[name=vipPrice]").prop("checked"))
                url += "&vipPrice=100";
            else
                url += "&vipPrice=0";
            url += "&salesPlatform=" + $("#salesPlatform").val()


            if ($mainDataTable) {
                $mainDataTable.api().ajax.url(url).load();
                return;
            }
            var dtSetting = $.dataTableSetting({
                "ajaxSource": url,
                "serverSide": true,
                "bFilter": false,// 去掉搜索框
                "bLengthChange": true,// 每页显示数量
                "sScrollX": "100%",
                "sScrollXInner": "100%",
                "iDisplayLength": 25,

                "bSort": false,
                "aoColumns": [{
                    "mDataProp": "id",
                    "sTitle": "商品ID",
                    "width": "7%"
                }, {
                    "mDataProp": "productCode",
                    "sTitle": "商品编码",
                    "width": "10%",
                    "class": "productCode",
                    "render": function (data, type, row) {
                        var s = row.salesPlatform;
                        s = s.replace("Yiigoo", "壹果").replace("Yijiadian", "壹家店")

                        s = "<br><span class='alert alert-danger' style='padding:2px'>" + s + "</span>";
                        if (row.sendType == "SupplierSend") {
                            return row.productCode + "<br><br><span class='alert alert-success' style='padding:2px'>商家发货</span>" + s;
                        }
                        return "<a target=_blank href=sku_list.html?productcode=" + row.productCode + ">" + row.productCode + '</a><br><br><span class="alert alert-info" style="padding:2px">壹果发货</span>' + s;

                    }
                }, {
                    "mDataProp": "productName",
                    "sTitle": "商品名称",
                    "width": "23%",
                    "render": function (data, type, row) {

                        var price = row.productSalePrice.toFixed(2);
                        var sourceprice = row.productOriginalPrice;
                        if (row.promotionPrice > 0) {
                            price += "(拼团价:" + row.promotionPrice.toFixed(2) + ")";
                        }
                        if (row.vipPrice > 0) {
                            price += "(会员价:" + row.vipPrice.toFixed(2) + ")";
                        }
                        var preDate = "";
                        if (row.preSaleDate != null)
                            preDate = "<br><span class='text-danger'>预售期：" + row.preSaleDate + "</span>";
                        var imagePath = "";
                        if (row.imagePath != null) {
                            imagePath = getProductImage(row.imagePath, "-200*200.jpg");
                        }
                        return "<div style='display: inline-flex'><div><img width=100 height=100 src=" + imagePath + "></div><div><a href='" + App.getDomain() + "/product/product.html?productId=" + row.id + "' target='_blank'>" + row.productName + "</a><br><span class='text-danger'>￥" + price + " 原价：" + sourceprice + "</span>" + preDate + "<br>分享返利：" + row.shareRate + "</div></div>";
                    }
                }, {
                    "sTitle": "商品分类",
                    "mDataProp": "categoryNames",
                    "width": "9%"
                }
                    , {
                        "mDataProp": "groupName",
                        "sTitle": "商品款式 ",
                        "width": "10%",
                        "render": function (data, type, row) {
                            return "<a target=_blank href=group_list.html?type=Web&q=" + row.groupName + ">" + row.groupName;
                        }
                    }
                    , {
                        "mDataProp": "saleStatus",
                        "sTitle": "状态",
                        "width": "7%",
                        "class": "saleStatus",
                        "render": function (data, type, row) {
                            if (row.saleStatus == "OnSale")
                                return "上架";
                            if (row.saleStatus == "Invisible")
                                return "上架不可见";
                            return "下架";

                        }

                    }, {
                        "mDataProp": "createTime",
                        "sTitle": "创建时间",
                        "width": "8%",
                        "render": function (data, type, row) {
                            return $.getLocalTime(row.createTime);
                        }
                    }, {
                        "mDataProp": "updateTime",
                        "sTitle": "发布时间",
                        "width": "8%",
                        "class": "saleTime",
                        "render": function (data, type, row) {
                            if (row.saleTime != null)
                                return $.getLocalTime(row.saleTime);
                            return "";
                        }
                    }, {
                        "sTitle": "操作",
                        "render": function (data, type, row) {
                            var str = "<p class='btn-toolbar' style='margin:0px'>";
                            if (App.checkButton("Product:OnSales") && row.saleStatus == "InStock")
                                str += "<a class='btn btn-warning btn-xs bt_sales btn-width' style='width:80px;margin-left:0px;margin-right:5px;margin-top:2px;' productcode='" + row.productCode + "'><i class='fa " + (row.saleStatus == "OnSale" ? "fa-arrow-circle-o-down" : "fa-arrow-circle-o-up") + "'></i>" + ((row.saleStatus == "OnSale" || row.saleStatus == "Invisible") ? "下架" : "上架") + "</a>";
                            if (App.checkButton("Product:InStock") && (row.saleStatus == "OnSale" || row.saleStatus == "Invisible"))
                                str += "<a class='btn btn-warning btn-xs bt_sales btn-width' style='width:80px;margin-left:0px;margin-right:5px;margin-top:2px;'><i class='fa " + ((row.saleStatus == "OnSale" || row.saleStatus == "Invisible") ? "fa-arrow-circle-o-down" : "fa-arrow-circle-o-up") + "'></i>" + ((row.saleStatus == "OnSale" || row.saleStatus == "Invisible") ? "下架" : "上架") + "</a>";

                            if (App.checkButton("Product:Edit"))
                                str += "<a target='_blank' class='btn btn-success btn-xs bt_edit btn-width' style='width:80px;margin-left:0px;margin-right:5px;margin-top:2px;' href='add_product.html?id=" + row.id + "&flag=edit'><i class='fa fa-pencil-square-o'></i>编辑</a>";
                            str += "<a target='_blank' class='btn btn-danger btn-xs bt_del btn-width' style='width:80px;margin-left:0px;margin-right:5px;margin-top:2px;'><i class='fa fa-trash-o'></i> 删除</a>";
                            str += "<a target='_blank' class='btn btn-primary btn-xs bt_add btn-width' style='margin-left:0px;margin-right:5px;margin-top:2px;' href='add_product.html?id=" + row.id + "&flag=group'><i class='fa fa-copy'></i>添加同款</a>";
                            str += "<a class='btn btn-purple btn-xs btn-width' style='margin-left:0px;margin-right:5px;margin-top:2px;' href='add_product.html?id=" + row.id + "&flag=copy'><i class='fa fa-thumbs-up icon-white'></i>复制商品</a>";

                            str += "<a class='btn btn-info btn-xs bt_product_pre_sales btn-width' style='margin-left:0px;margin-right:5px;margin-top:2px;' id='" + row.id + "' preSaleDate='" + row.preSaleDate + "'><i class='fa fa-thumbs-up icon-white'></i>预售管理</a>";
                            if (App.checkButton("Product:Price"))
                                str += "<a class='btn btn-grey btn-xs bt_price btn-width' style='margin-left:0px;margin-right:5px;margin-top:2px;'  " +
                                    "id='" + row.id + "' productSalePrice='" + row.productSalePrice + "' vipPrice='" + row.vipPrice
                                    + "' promotionPrice='" + row.promotionPrice + "' shareRate='" + row.shareRate + "' distributionPrice='" + row.distributionPrice
                                    + "'><i class='fa fa-thumbs-up icon-white'></i>一键改价</a>";
                            if (App.checkButton("Product:IsSprice"))
                                str += "<a class='btn btn-primary btn-xs bt_special btn-width' style='margin-left:0px;margin-right:5px;margin-top:2px;'  id='" + row.id + "' isSpecial='" + row.isSpecial + "'><i class='fa fa-copy'></i>设置特例品</a>";
                            str += "<a class='btn btn-primary btn-xs bt_productComment btn-width' style='margin-left:0px;margin-right:5px;margin-top:2px;'  id='" + row.id + "' productName='" + row.productName + "'><i class='fa fa-copy'></i>商品评价</a>";
                            str += "<a class='btn btn-warning btn-xs bt_pushOffShop btn-width' style='margin-left:0px;margin-right:5px;margin-top:2px;width:100px;'  id='" + row.id + "' pushKids='" + row.pushKids + "'><i class='fa fa-copy'></i>推送到线下店</a>";
                            str += "</p>"
                            return str;
                        }
                    }, {
                        "mDataProp": "id",
                        "class": "id hide"
                    }, {
                        "mDataProp": "saleStatus",
                        "class": "salesStatus hide"
                    }, {
                        "mDataProp": "productName",
                        "class": "productName hide"
                    }, {
                        "mDataProp": "shortName",
                        "class": "color hide"
                    }, {
                        "mDataProp": "productSalePrice",
                        "class": "productSalePrice hide"
                    }]
            });

            $mainDataTable = $("#db_product_list").dataTable(dtSetting);
        };

        var getManImage = function (productImages) {
            for (var i = 0; i < productImages.length; i++) {
                var isMain = productImages[i].isMain;
                if (isMain == true || isMain == 'true') {
                    return productImages[i].imagePath;
                }
            }
            return null;
        }
        var updateSaleTime = function (time, saleStatus, productCode) {
            $.ajax({
                type: "post",
                url: App.getContextPath() + "admin/product/updateSalesStatus.do",
                async: true,
                data: {
                    id: id,
                    saleStatus: saleStatus,
                    saleTime: time,
                    productCode: productCode
                },
                success: function (result) {
                    if (result.type == "error") {
                        $.alert(result.extra);
                    }
                    $("#sales_time_config").modal("hide");
                    $("#sales_config").modal("hide");
                    //searchProduct();
                }
            });
        }
        var loadSupplier = function () {
            $.ajax({
                type: "get",
                url: App.getContextPath() + "admin/store/searchSupplierList.do",
                async: true,
                success: function (result) {
                    if (result != null) {
                        var data = eval(result);
                        var option = "<option value=''>选择店铺</option>";
                        $.each(data, function (index, item) {
                            option += "<option value='" + item.id + "'>" + item.supplierName + "</option>";
                        });
                        $("#supplier_select").empty().append(option).select2();
                    }
                }
            });
        };
        var vipRateChange = function (rate) {
            var promotionPrice = $("#update_price_config").find("input[name=promotionPrice]").val();
            var vipPrice;
            if (promotionPrice && promotionPrice > 0) {
                vipPrice = Math.floor(promotionPrice * (1 - rate))
            } else {
                var productSalePrice = $("#update_price_config").find("input[name=productSalePrice]").val();
                vipPrice = Math.floor(productSalePrice * (1 - rate))
            }

            $("#update_price_config").find("input[name=vipPrice]").val(vipPrice);

        }
        var loadGroup = function () {
            $.ajax({
                type: "get",
                url: App.getContextPath()
                    + "admin/group/searchGroupList.do",
                async: true,
                success: function (result) {
                    if (result != null) {
                        var data = eval(result);
                        var option = "<option promotionPrice=0></option>";
                        $
                            .each(
                                data,
                                function (index, item) {
                                    option += "<option value='"
                                        + item.id
                                        + "' promotionPrice='"
                                        + (item.promotionPrice == null ? 0
                                            : item.promotionPrice)
                                        + "'>"
                                        + item.groupName
                                        + "</option>";
                                });
                        $("#group_select").empty().append(option);
                        $("#s2id_select_group").select2({placeholder: "选择款式"})
                    }
                }
            })
        }
        var pushKis = function () {
            $("#push_off_shop_config").find("input[type=checkbox]").prop("checked", false);
            var pushKids = $(this).attr("pushKids");
            if (pushKids === 'true') {
                $("#push_off_shop_config").find("input[value=Kids]").prop("checked", true);
                $("#push_off_shop_config").find("input[value=Kids]").prop("disabled", true);
            } else {
                $("#push_off_shop_config").find("input[value=Kids]").removeAttr("disabled");
            }
            $("#push_off_shop_config").modal("show");
            var tr = $(this).closest("tr");
            var productId = $(tr).find(".id").html();

            $("#push_off_shop_config .bt-push").unbind().click(function () {
                var offShops = $("#push_off_shop_config").find("input[name=offShop]:checked:not(:disabled)").val();
                if (offShops && offShops.length > 0) {
                    $.post(App.getContextPath() + "admin/product/pushProductInfoToKids.do", {productId: productId, offShops: offShops}, function (result) {
                        if (result.type === 'success') {
                            $.alert("推送成功");
                            $("#push_off_shop_config").modal("hide");
                            // searchProduct();
                        } else {
                            $.alert(result.content);
                        }
                    });
                } else {
                    $.alert("请选择要推送的线下店");
                }
            });
        }
        /**
         * 批量更新产品名称
         */
        var batchUpdateProductName = function () {
            var searchKey = $("#update_productName_config").find("[name=searchKey]").val();
            var distProductName = $("#update_productName_config").find("[name=distProductName]").val();

            if ($.trim(searchKey).length == 0 && selectProducts.length == 0) {
                $.alert("请输入原产品名称或查询选择产品")
                return;
            }
            $.confirm("确认批量更新产品名称，此操作不可恢复", function () {
                $.blockUI()
                $.post(App.getContextPath() + "admin/product/batchUpdateProdctName.do", {
                    searchKey: searchKey,
                    distProductName: distProductName,
                    productIds: selectProducts.toString()
                }, function (result) {
                    $.unblockUI()
                    $("#update_productName_config").modal("hide");
                    if (result.type === 'success') {
                        $.alert("更新成功");
                        searchProduct();

                    } else {
                        $.alert(result.content);
                    }
                });
            })
        }
        var $minDataTable = null;
        var searchProductName = function () {
            var q = $("input[name=q]").val();
            if (q == "")
                return;
            var url = App.getContextPath() + "admin/product/searchProductListForPromotion.do?q=" + $("input[name=q]").val();

            if ($minDataTable) {
                $minDataTable.api().ajax.url(url).load();
                return;
            }
            var dtSetting = $.dataTableSetting({
                "ajaxSource": url,
                "serverSide": true,
                "bFilter": false,// 去掉搜索框
                "bLengthChange": true,// 每页显示数量
                "sScrollX": "100%",
                "sScrollXInner": "100%",
                "iDisplayLength": 100,
                "paging": false,

                "bSort": false,
                "aoColumns": [{
                    "mDataProp": "id",
                    "sTitle": "商品ID",
                    "width": "15%"
                }, {
                    "mDataProp": "packTitle",
                    "sTitle": "产品名称",
                    "width": "50%",
                    "render": function (data, type, row) {

                        return "<div style='display: inline-flex'><div><img width=50 height=50 src=" + getProductImage(row.productImages[0].imagePath, "-200*200.jpg") + "></div><div><a href='" + App.getDomain() + "/product/product.html?productId=" + row.id + "' target='_blank'>" + row.productName + "</a></div></div>";

                    }
                }
                    , {
                        "sTitle": "颜色",
                        "mDataProp": "shortName",
                        "width": "20%"

                    }

                    , {
                        "sTitle": "操作",
                        "width": "15%",
                        "render": function (data, type, row) {
                            return "<a class='btn btn-success btn-add btn-width' pstatus='nojoin' href='javascript:;'>选中</a>";

                        }

                    }]
            });

            $minDataTable = $("#td_selectproduct").dataTable(dtSetting);
        }


        return {

            init: function () {


                $("#salesStatus").select2({placeholder: "选择状态"});
                $("#salesPlatform").select2()

                $(".search").click(searchProduct);
                $("#db_product_list").on("click", ".bt_sales", function () {
                    status = $(this).closest("tr").find(".salesStatus").html();
                    var txt = status != "InStock" ? "下架" : "上架";
                    id = $(this).closest("tr").find(".id").html();
                    var productcode = $(this).attr("productcode");
                    if (status == "InStock" && $(this).closest("tr").find(".saleTime").html() != "") {
                        $("#sales_time_config").modal("show");
                        $("#sales_time_config").find(".bt-save").off("click").on("click", function () {
                            var t = $("#sales_time_config").find("[name=saleTime]").val();
                            if (t == "") {
                                $.alert("请选择上架时间");
                                return false;
                            }
                            updateSaleTime(t, $("#sales_time_config").find("[name=saleStatus]:checked").val(), productcode);

                        });

                    } else {
                        if (txt == "下架") {
                            $.confirm("确认下架此产品?", function () {
                                updateSaleTime(null, "InStock", productcode);
                            });

                        } else {
                            $("#sales_config").modal("show");
                            $("#sales_config").find(".bt-save").off("click").on("click", function () {
                                updateSaleTime(null, $("#sales_config").find("[name=saleStatus]:checked").val(), productcode);

                            });
                        }


                    }
                });

                $("#db_product_list").on("click", ".bt_del", deleteProduct);
                $("#db_product_list").on("click", ".bt_productComment", showProductComment);
                $("#db_product_list").on("click", ".bt_product_pre_sales", updatePreSales);
                $("#db_product_list").on("click", ".bt_price", updatePrice);
                $("#db_product_list").on("click", ".bt_special", siteSpecial);
                $("#db_product_list").on("click", ".bt_pushOffShop", pushKis);
                $("#vipRate_select").select2().change(function () {
                    vipRateChange($(this).val())
                });
                searchProduct();
                $(".export").click(function () {
                    $("#export").submit();
                });
                //更新产品名称
                $(".batchUpdateName").click(function () {
                    $("#update_productName_config").modal("show");
                    selectProducts = [];
                    $("#update_productName_config").find("[name=q]").val('');
                    $("#update_productName_config").find("[name=distProductName]").val('');
                    $("#td_selectproduct").find("tbody").empty();
                    $("#update_productName_config").find(".bt-save").off("click").on("click", batchUpdateProductName)
                    //查询商品
                    $(".searchProductName").off("click").on("click", function () {
                        $("#update_productName_config").find("[name=searchKey]").val('');
                        searchProductName();

                        $("#td_selectproduct").off("click").on("click", ".btn-add", function () {
                            var tr = $(this).closest("tr");
                            var id = $(tr).find("td:eq(0)").html();
                            if ($(this).attr("pstatus") == "join") {//取消设置
                                selectProducts.remove(id, selectProducts)
                                $(this).attr("pstatus", "nojoin")
                                $(this).removeClass("btn-danger").addClass("btn-success").html("选中")
                            } else {//加入设置
                                selectProducts.push(id)
                                $(this).attr("pstatus", "join")
                                $(this).removeClass("btn-success").addClass("btn-danger").html("取消")
                            }
                        });
                    });
                })

            }
        }
    }();

    $(function () {
        $("#header").load("../head.html");

        App.init(); //Initialise plugins and elements
        Product.init();

    });
</script>
<!-- /JAVASCRIPTS -->
</body>
</html>